package main

import "fmt"

/**
结构体切片
*/
func main() {
	var m []student
	//使用奥鹏添加数据
	i := append(m, student{name: "zz", age: 10})
	fmt.Println(i)

	//结构体切片
	var n []student = []student{
		{101, "aasd", 11, "1"},
		{102, "aasd", 11, "1"},
		{103, "aasd", 11, "1"},
		{104, "aasd", 11, "1"},
	}
	fmt.Println(n)
	fmt.Println(n[0])
	//修改结构体中内容
	n[0].age = 22
	for i := 0; i < len(n); i++ {
		fmt.Println(n[i])
	}
	for i, v := range n {
		fmt.Println(i)
		fmt.Println(v)
		//fmt.Println(v.id)  获取具体的属性信息
	}

}

type students struct {
	//这里不能加var关键字
	id   int
	name string
	age  int
	addr string
}
